
void check( buffer a, string b )
{
	a.append( "<span style='color:green'>&#10003; " );
	a.append( b );
	a.append( "</span><br />");
}

void batsu( buffer a, string b )
{
	a.append( "<span style='color:red'>&#10007;</span> " );
	a.append( b );
	a.append( "<br />" );
}

buffer manor( buffer source )
{
	buffer info;
	#info.append( "<div style='text-align:center; color:blue; font-family:serif'>" );
	info.append( "<div style='margin-left:auto; margin-right:auto; display:table; color:blue; font-family:serif'>" );

	// Report Library status
	if ( item_amount( $item[spookyraven library key] ) > 0 )
		info.check( "Library open" );
	else
		info.batsu( "Library locked" );

	// Report Gallery status
	if ( item_amount( $item[spookyraven gallery key] ) > 0 )
		info.check( "Gallery open" );
	else if ( to_int( get_property( "lastGalleryUnlock" ) ) == my_ascensions() )
		info.batsu( "Gallery key available in Conservatory" );
	else
		info.batsu( "Gallery key requires reading in Library" );

	// Report Second Floor status
	if ( !source.contains_text( "manor2.php" ) )
	{
		info.batsu( "Upstairs closed" );
		// Remove treacherous link to the second floor
		source.replace_string( '<a href="manor.php?place=stairs">', "" );
	} else
		info.check( "Upstairs open" );

	if( item_amount( $item[Spookyraven ballroom key] ) > 0) {
		// Report Ballroom Quartet song setting
		if( get_property("lastQuartetAscension").to_int() == my_ascensions() ) {
			switch( get_property( "lastQuartetRequest" ) )
			{
				case "1": info.check( "Ballroom playing ML boost" );
					break;
				case "2": info.check( "Ballroom playing <b>non-combat</b>" );
					break;
				case "3": info.check( "Ballroom playing item bonus" );
					break;
				default: info.batsu( "Ballroom Quartet disabled" );
			}
		} else
			info.batsu( "Ballroom song unset" );
	} else
		info.batsu( "Ballroom locked" );

	info.append( "</div>" );
	return insert( source, index_of( source, "</table>" ) + 8, info );
}

void main( )
{
   write( manor( visit_url() ) );
}
